<script setup>
//响应式函数
import {ref} from 'vue'

const style = ref('style1')

//定义函数
const changeColor = ()=>{//箭头函数
  //析构
  if (style.value === 'style1'){
    style.value = 'style2'
  }else {
    style.value = 'style1'
  }
}

</script>

<template>
    <div :class="style" @click="changeColor"></div>
</template>

<style scoped>
  .style1{
    width: 120px;
    height: 120px;
    background-color: red;
  }
  .style2{
    width: 200px;
    height: 200px;
    background-color: blue;
  }
</style>